import delimited "C:\Users\Jungyeon PARK\Dropbox\DISCRIMINATION PROJECT (U.S. FEDERAL AGENCIES)\FEVS\FEVS_2010-2019\FEVS2010_PRDF.csv

svyset [pweight=postwt]

drop if q17=="X"

drop if q17==""

drop if q37=="X"

drop if q37==""

drop if q38=="X"

drop if q38==""

destring q17, replace

destring q37, replace

destring q38, replace

svy linearized : gsem (FAIRNESS -> q17, family(ordinal) link(logit)) (FAIRNESS -> q37, family(ordinal) link(logit)) (FAIRNESS -> q38, family(ordinal) link(logit)), covstruct(_lexogenous, diagonal) latent(FAIRNESS) nocapslatent

predict fairnessgsem, latent(FAIRNESS)

egen average_fairnessgsem = mean (fairnessgsem), by (agency)

egen sub_average_fairnessgsem = mean (fairnessgsem), by (subelem)

svy linearized : sem (FAIRNESSSEM -> q38 q37 q17), covstruct(_lexogenous, diagonal) standardized latent(FAIRNESSSEM) nocapslatent

estat gof, stats(all)

predict fairnesssem, latent(FAIRNESSSEM)

egen average_fairnesssem = mean (fairnesssem), by (agency)

egen sub_average_fairnesssem = mean (fairnesssem), by (subelem)

correlate fairnessgsem fairnesssem
